﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HKEA.CMS.Core;
using HKEA.CMS.Core.BLL;
using HKEA.CMS.Core.Models;
using HKEA.CMS.Core.BLL.Tbl;

namespace WebApplication
{
    public partial class AjaxTextNicky : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
            }
        }

        #region
        //[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        //public static string[] GetCustomerIDList(string prefixText, int count, string contextKey)
        //{
        //    tblCustomer entCustomer = new tblCustomer();
        //    tblCustomerBLL bllCustomer = new tblCustomerBLL();
        //    List<tblCustomer> listCustomer = bllCustomer.GetListByENT(entCustomer);
        //    var Customer = listCustomer.Select(p => p.CustomerID).Where(p => p.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase)).Take(10).ToArray();
        //    return Customer;
        //}

        //[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        //public static string[] GetCustomerNameList(string prefixText)
        //{
        //    tblCustomer entCustomer = new tblCustomer();
        //    tblCustomerBLL bllCustomer = new tblCustomerBLL();
        //    List<tblCustomer> listCustomer = bllCustomer.GetListByENT(entCustomer);
        //    List<NewListResule> listTitle = new List<NewListResule>();
        //    List<NewListResule> listResule = new List<NewListResule>();

        //    foreach (tblCustomer item in listCustomer)
        //    {
        //        NewListResule entNewList = new NewListResule();
        //        if (!String.IsNullOrEmpty(item.Name_Chi))
        //        {
        //            entNewList.Title = item.Name_Eng;
        //            listTitle.Add(entNewList);
        //            entNewList.Title = item.Name_Chi;
        //            listTitle.Add(entNewList);
        //        }
        //    }
        //    var equ = listTitle.Where(a => a.Title.Contains(prefixText)).ToList();
        //    foreach (var item in equ)
        //    {
        //        NewListResule entNewList = new NewListResule();
        //        entNewList.Title = item.Title.ToString();
        //        listResule.Add(entNewList);
        //    }
        //    var val = listResule.Select(p => p.Title).Take(10).ToArray();
        //    return val;
        //}
//        public static string[] GetCustomerNameList(string prefixText, int count, string contextKey)
//        {
//            tblCustomer entCustomer = new tblCustomer();
//            tblCustomerBLL bllCustomer = new tblCustomerBLL();
//            List<tblCustomer> listCustomer = bllCustomer.GetListByENT(entCustomer);
//            List<NewListResule> listTitle = new List<NewListResule>();
//            foreach (tblCustomer item in listCustomer)
//            {
//                NewListResule entNewList = new NewListResule();
                
//                entNewList.Title = item.Name_Eng;
//                listTitle.Add(entNewList);
//                entNewList.Title = item.Name_Chi;
//                listTitle.Add(entNewList);
//            }
//            //var Title = listTitle.Select(p => p.Title).Where(p => p.StartsWith(prefixText, StringComparison.Ordinal)).Take(count).ToArray();
//            var Title = listTitle.Select(p => p.Title).Where(p => p.StartsWith(prefixText, StringComparison.Ordinal)).Take(count).ToArray();
//            return Title;

////            string[] movies = {"比亞聯合有限公司" ,"立基洋行有限公司","蒙地奧香港有限公司","黛安芬國際海外有限公司香港分公司 ","恒生銀行","渣打銀行(香港)有限公司"
////, "Shrek", "Shrek II" };
////            return (from m in movies where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray(); 
//        }
#endregion
        public static List<NewListResule> GetCustomerNameList()
        {
            tblCustomer entCustomer = new tblCustomer();
            tblCustomerBLL bllCustomer = new tblCustomerBLL();
            List<tblCustomer> listCustomer = bllCustomer.GetListByENT(entCustomer);
            List<NewListResule> listTitle = new List<NewListResule>();
            List<NewListResule> listResule = new List<NewListResule>();
            NewListResule entNewList = null;
            foreach (tblCustomer item in listCustomer)
            {
                entNewList = new NewListResule();
                if (!String.IsNullOrEmpty(item.Name_Chi))
                {
                    entNewList.Title = item.Name_Chi;
                    listTitle.Add(entNewList);
                }
                entNewList = new NewListResule();
                if (!String.IsNullOrEmpty(item.Name_Eng))
                {
                    entNewList.Title = item.Name_Eng;
                    listTitle.Add(entNewList);
                }
            }
            listResule = listTitle.Distinct().ToList();
            return listResule;
        }

        public List<string> tblAdress() { 
            tblAddress ent=new tblAddress();
            tblAddressBLL bll = new tblAddressBLL();
            List<tblAddress> list = bll.GetListByENT(ent);
            List<string> T = new List<string>();

            foreach (tblAddress item in list) {
                if (!string.IsNullOrEmpty(item.City_Eng))
                {                    
                    T.Add(item.City_Eng.ToString());
                }
            }
            T = T.Distinct().ToList();
            return T;
        }
    }
}